const http = require('http')
const https = require('https')

const app = http.createServer((request, response) => {
  //MIME类型

  // response.writeHead(200, {
  //   'content-type': 'application/json;charset=utf-8'
  // })


  response.write(JSON.stringify({x: 0}))

  // https.get('https://www.xiaomiyoupin.com/homepage/main/v1002?platform=pc', res=>{
  //   let data = ''
  //   res.on('data', (chunk) => {
  //     data += chunk
  //   })
  //   res.on('end', () => {
  //     let source = JSON.parse(data)
  //     let json = JSON.stringify({
  //       ret: true,
  //       data: source.data.homepage.floors
  //     })
  //     response.end(json)
  //   })
  // })

  response.end()
})

app.listen(8080, () => console.log('localhost:8080'))